package com.ruicar.afs.cloud.bizcommon.face.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.ruicar.afs.cloud.bizcommon.face.feign.FaceRecognitionFeign;
import com.ruicar.afs.cloud.bizcommon.face.service.FaceRecognitionService;
import com.ruicar.afs.cloud.bizcommon.face.util.FaceConfig;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName FaceRecognitionServiceImpl
 * @Description: 人脸识别(思图)
 * @Author mingzhi.li
 * @Date 2020/8/7
 * @Version V1.0
 **/
@Slf4j
@Service
@Component
@AllArgsConstructor
public class FaceRecognitionServiceImpl implements FaceRecognitionService {
    private FaceConfig faceConfig;
    private FaceRecognitionFeign faceRecognitionFeign;
    @Override
    public JSONObject FaceRecognitionCheck(JSONObject json) {
        //请求头
        Map headers = makeHeader();
        JSONObject result = faceRecognitionFeign.faceRecognitionCheck(json, headers);
        return result;
    }
    /**
     * 获取请求头
     *
     * @return
     */
    public Map makeHeader() {
        Map headers = new HashMap<>();
        headers.put("X-Auth-Token", faceConfig.getXAuthToken());
        return headers;
    }
}
